#include "widget.h"
#include "ui_widget.h"
#include "config.h"
#include <QPainter>
#include <QDebug>
#include "mypushbotton.h"
#include "playscene.h"
#include "intro.h"
#include <QTimer>
#include <QSound>
#include <QFileInfo>

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ///////////////////////////////////////////////////////
    ui->setupUi(this);
    //设置固定大小
    initScene();
    ////////////////////////////////////////////////////////
    QSound::play(bgm);

    //开始按钮
    introduction = new intro;
    myPushBotton * startbtn = new myPushBotton(":/resource/start.png");
    startbtn->setParent(this);
    startbtn->move(this->width()*0.5 - startbtn -> width()*0.5,this->height()*0.75);
    connect(startbtn,&myPushBotton::clicked,[=](){
        qDebug()<<"点击了开始";
        startbtn->zoom1();
        startbtn->zoom2();
        ///////////////////////
        //进入下一个场景
        QTimer::singleShot(1000,this,[=](){
            this->hide();
            introduction->show();
        });

    });

    /////////////////////////////////////////////////////
    //介绍场景

}
void Widget::paintEvent(QPaintEvent *)
{
    QPainter painter(this);
    QPixmap pix;
    pix.load(":/resource/pub4.jpg");
    painter.drawPixmap(0,0,pix);
    pix.load(":/resource/theBartender.png");
    painter.drawPixmap(this->width()*0.5-pix.width()*0.5,50,pix);
}
void Widget::initScene()
{
    setFixedSize(gamew,gameh);
    setWindowIcon(QPixmap(gameicon));
    setWindowTitle(gametitle);
}
Widget::~Widget()
{
    delete ui;
}

